package ChainOfResponsibility;

public abstract class Support {
    private String name;
    private Support next;
    public Support(String name) {
        this.name = name;
    }
    public Support setNext(Support next) {
        this.next = next;
        return next;
    }
    public void support(Data Data) {
        if(resolve(Data)) {
            done(Data);
        } else {
            fail(Data);
        }
    }
    @Override
    public String toString() {
        return "[" + name + "]";
    }
    public abstract boolean resolve(Data Data);
    protected void done(Data Data){
        System.out.println(Data + " is handled by " + this + ".");
    }
    protected void fail(Data Data){
        System.out.println(Data + " cannot be handled");
    }

}
